﻿using UnityEngine;
using System.Collections;
using Memo.Electricity.Engine;
using UnityEngine.SceneManagement;


namespace Memo.Electricity.Game
{
	public class CGameMgr : MonoBehaviour
	{
		private void Awake()
		{
			DontDestroyOnLoad(gameObject);

			//实例化各种单例
			CAudioMgr.Inst.enabled = true;
			CCoroutineMgr.Inst.enabled = true;
			CEventMgr.Inst.enabled = true;
			CTickMgr.Inst.enabled = true;
			CLevelMgr.Inst.enabled = true;
		}

		private void OnEnable()
		{
			CAudioMgr.Inst.PlayBGM("Audios/bgm");
			SceneManager.LoadScene(1);
		}

		private void Update()
		{
			if(Input.GetKeyDown(KeyCode.Escape))
			{
				if (SceneManager.GetActiveScene().buildIndex > 1)
				{
					CLevelMgr.Inst.BackToStartScene();
				}
			}
			if (Input.GetKeyDown(KeyCode.R))
			{
				if (SceneManager.GetActiveScene().buildIndex > 1)
				{
					CLevelMgr.Inst.RestartCurrentLevel();
				}
			}
		}

	}
}